use sqlx::SqlitePool;

use crate::{error::AppErr, global::APP};

pub mod track;

pub async fn new_sqlite_pool(path: &str) -> Result<SqlitePool, AppErr> {
    let url = format!("sqlite://{}/./data.db?mode=rwc", path);
    let pool = SqlitePool::connect(&url).await?;
    Ok(pool)
}

pub async fn init() -> Result<(), AppErr> {
    track::init().await?;
    Ok(())
}

#[inline(always)]
pub fn get_pool() -> &'static SqlitePool {
    &APP.pool
}








